package com.qian.apiserver.service;

import com.qian.apiserver.entity.GmVersion;
import com.qian.apiserver.model.Version;
import org.springframework.beans.factory.annotation.Autowired;
import com.yaowk.service.common.BaseRepository;
import java.lang.String;
import com.yaowk.service.common.BaseServiceImpl;
import java.lang.Integer;
import com.qian.apiserver.service.IVersionService;
import com.qian.apiserver.dao.VersionDao;

public abstract class VersionServiceBase extends BaseServiceImpl<Version, GmVersion, Integer> implements IVersionService {

	@Autowired
	private VersionDao dao;

	@Override protected VersionDao getDao() {
	return dao;
	}

	@Override
	protected Version entity2model(GmVersion entity) {
		Version model = null;
		if(isNotEmpty(entity)){
			model = new Version();
			model.setId(entity.getId());
			model.setVersion(entity.getVersion());
			model.setVersionContent(entity.getVersionContent());
		}
		return model;
	}

	@Override
	protected GmVersion model2Entity(Version model) {
		GmVersion entity = null;
		if(isNotEmpty(model)){
			entity = new GmVersion();
			entity.setId(model.getId());
			entity.setVersion(model.getVersion());
			entity.setVersionContent(model.getVersionContent());
		}
		return entity;
	}

	@Override
	protected GmVersion updateParams(Version model) {
		GmVersion entity = dao.findOne(model.getId());
		if(isNotEmpty(model.getVersion()))
			entity.setVersion(model.getVersion());
		if(isNotEmpty(model.getVersionContent()))
			entity.setVersionContent(model.getVersionContent());
		return entity;
	}


}